// ignore_for_file: must_be_immutable

import 'package:aitao_flutter/res/r.dart';
import 'package:aitao_flutter/utils/sp_utils.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import '../../common_ui/empty_view.dart';
import '../../model/hello_img_model.dart';
import '../../style/edgeInsets_style.dart';
import '../../style/text_style.dart';

class SayHelloImagePage extends StatefulWidget {
  SayHelloImagePage({Key? key, required this.imageList}) : super(key: key);
  List<HelloImageModel> imageList = [];
  @override
  State<SayHelloImagePage> createState() => _SayHelloImagePageState();
}

//
class _SayHelloImagePageState extends State<SayHelloImagePage> {
  @override
  Widget build(BuildContext context) {
    return widget.imageList.isEmpty
        ? EmptyView()
        : Container(
            padding: EdgeInsetsStyle.all(10),
            child: GridView.builder(
                itemCount: widget.imageList.length,
                gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
                    crossAxisCount: 3,
                    crossAxisSpacing: 10,
                    mainAxisSpacing: 10),
                itemBuilder: (context, index) {
                  HelloImageModel model = widget.imageList[index];
                  return Container(
                    color: Colors.teal,
                    child: Stack(
                      children: [
                        Positioned(
                            child: CachedNetworkImage(
                          imageUrl: SpUtil.getImageUrl(model.imgPath ?? ''),
                        )),
                        Visibility(
                          visible: model.isAudit == 0,
                          child: Positioned(
                              child: Container(
                            color: const Color.fromRGBO(29, 29, 29, 0.58),
                            child: Center(
                              child: Text(
                                '审核中',
                                style: Styles.whiteText_13,
                              ),
                            ),
                          )),
                        ),
                        Positioned(
                            right: 0,
                            child: Image.asset(ImagePath.assetsDeleteBtn)),
                      ],
                    ),
                  );
                }));
  }
}
